/***************************************************************************
 *   Copyright (C) 2008 by Goliash   *
 *   goliash@goliash.net   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
 #include "info_dialog.h"

InfoDialog::InfoDialog(QWidget *parent) : QDialog(parent)
{
	setupUi(this);
}

void InfoDialog::setData(QSqlQuery query)
{
	if(query.next()) {
		infoWidget->setRowCount(7);
		infoWidget->setColumnCount(2);
		infoWidget->setColumnWidth(0, 180);
		infoWidget->setColumnWidth(1, 350);

		infoWidget->setItem(0, 0, new QTableWidgetItem("Medium name"));
		infoWidget->setItem(0, 1, new QTableWidgetItem(query.value(0).toString()));

		infoWidget->setItem(1, 0, new QTableWidgetItem("Medium name (original)"));
		infoWidget->setItem(1, 1, new QTableWidgetItem(query.value(1).toString()));

		infoWidget->setItem(2, 0, new QTableWidgetItem("Added to database"));
		infoWidget->setItem(2, 1, new QTableWidgetItem(query.value(2).toString()));

		infoWidget->setItem(3, 0, new QTableWidgetItem("Creator application"));
		infoWidget->setItem(3, 1, new QTableWidgetItem(query.value(3).toString()));

		infoWidget->setItem(4, 0, new QTableWidgetItem("Creation time"));
		infoWidget->setItem(4, 1, new QTableWidgetItem(query.value(4).toString()));

		infoWidget->setItem(5, 0, new QTableWidgetItem("Exploring time"));
		infoWidget->setItem(5, 1, new QTableWidgetItem(query.value(5).toString()));

		infoWidget->setItem(6, 0, new QTableWidgetItem("Medium size"));
		infoWidget->setItem(6, 1, new QTableWidgetItem( QString::number(query.value(6).toDouble()/(1024*1024)) + QString(" MB") ));
	}
	else
		qDebug() << "error in sql data";
}

